package loop;

import java.util.Scanner;

public class LoopWhileFor_4 {
    public static void main ( String [] args){
        int number = 1 ;
        boolean flag = true ;
        int i = 2 ;
      /*  Scanner scanner = new Scanner( System.in ) ;
        System.out.println( "请输入您要判断的数值:" ) ;
        number = scanner.nextInt() ;
        System.out.println(System.currentTimeMillis());

        while ( i < Math.sqrt(number)) {
            if ( number % i == 0){
                flag = false ;
                break ;
            }
            i++;
        }
        */
        /*
        for ( i = 2 ; i <= Math.sqrt(number) ; i++){
            if ( number % i == 0){
                flag = false ;
                break ;
            }
        }
        if ( flag ) {
            System.out.println( number + "是质数。" );
        }else{
            System.out.println( number + "不是质数。" );
        }
        */
        int count = 0;
        while ( number <= 100) {
            for (i = 2; i <= Math.sqrt(number); i++) {
                if (number % i == 0) {
                    flag = false;
                   break;
                }
            }
            if (flag) {
                System.out.println(number);
                count++;
            }

            flag = true ;
            number++;
        }
        System.out.println(count);
        System.out.println(System.currentTimeMillis());
    }
}
